//
//  SmallDecisionsFxqSelectTypeViewController.h
//  SmallDecisions
//
//  Created by 李付雄 on 2025/08/28.
//

#import "SmallDecisionsFxqSelectTypeViewController.h"

@interface SmallDecisionsFxqSelectTypeViewController ()

@end

@implementation SmallDecisionsFxqSelectTypeViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.edgesForExtendedLayout = UIRectEdgeNone;

    UIView *fxqTypeOneCell = [self createSmallDecisionsFxqTypeCellWithIcon:@"samll_deci_fxq_style_one_icon" title:@"暧昧模式" content:@"最经典的模式，适合刚刚开始接触的情侣对象" tag:1];
    [self.view addSubview:fxqTypeOneCell];
    [fxqTypeOneCell mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(10);
        make.left.mas_equalTo(self.view).mas_offset(15);
        make.right.mas_equalTo(self.view).mas_offset(-15);
    }];

    UIView *fxqTypeTwoCell = [self createSmallDecisionsFxqTypeCellWithIcon:@"samll_deci_fxq_style_two_icon" title:@"热恋模式" content:@"进一步的接触模式，让彼此真诚相待，互相融入。" tag:2];
    [self.view addSubview:fxqTypeTwoCell];
    [fxqTypeTwoCell mas_makeConstraints:^(MASConstraintMaker *make) {

        make.top.mas_equalTo(fxqTypeOneCell.mas_bottom).mas_offset(15);
        make.left.right.mas_equalTo(fxqTypeOneCell);
    }];

    UIView *fxqTypeThreeCell = [self createSmallDecisionsFxqTypeCellWithIcon:@"samll_deci_fxq_style_three_icon" title:@"火热模式" content:@"敏感而刺激的模式，触及深处，未成年人禁止进入。" tag:3];
    [self.view addSubview:fxqTypeThreeCell];
    [fxqTypeThreeCell mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(fxqTypeTwoCell.mas_bottom).mas_offset(15);
        make.left.right.mas_equalTo(fxqTypeOneCell);
    }];

    UIView *fxqTypeFourCell = [self createSmallDecisionsFxqTypeCellWithIcon:@"samll_deci_fxq_style_four_icon" title:@"混合模式" content:@"所有的挑战随机出现，让彼此一次体验够。" tag:4];
    [self.view addSubview:fxqTypeFourCell];
    [fxqTypeFourCell mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(fxqTypeThreeCell.mas_bottom).mas_offset(15);
        make.left.right.mas_equalTo(fxqTypeOneCell);
    }];
}

- (UIView *)createSmallDecisionsFxqTypeCellWithIcon:(NSString *)icon
                                              title:(NSString *)title
                                            content:(NSString *)content
                                                tag:(NSInteger)tag{

    UIView *cellContainerView = [[UIView alloc] init];
    cellContainerView.tag = tag;
    cellContainerView.backgroundColor = SmallDecisionsSecondBgColor;
    cellContainerView.layer.cornerRadius = 6;
    cellContainerView.layer.masksToBounds = YES;

    UIImageView *iconImageView = [[UIImageView alloc] init];
    iconImageView.image = [UIImage imageNamed:icon];
    [cellContainerView addSubview:iconImageView];
    [iconImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.mas_equalTo(10);
        make.width.height.mas_equalTo(20);
    }];

    UILabel *titleLabel = [[UILabel alloc] init];
    titleLabel.textColor = SmallDecisionsThemeFontColor;
    titleLabel.font = SmallDecisionsSetFontSize(18);
    titleLabel.numberOfLines = 1;
    titleLabel.text = title;
    [cellContainerView addSubview:titleLabel];
    [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(iconImageView.mas_centerY);
        make.left.mas_equalTo(iconImageView.mas_right).mas_offset(10);
        make.right.mas_equalTo(-10);
    }];

    UILabel *contentLabel = [[UILabel alloc] init];
    contentLabel.textColor = SmallDecisionsLineHeightColor;
    contentLabel.font = SmallDecisionsSetFontSize(12);
    contentLabel.numberOfLines = 2;
    contentLabel.text = content;
    [cellContainerView addSubview:contentLabel];
    [contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(iconImageView.mas_bottom).mas_offset(10);
        make.left.mas_equalTo(10);
        make.right.mas_equalTo(-10);
        make.bottom.mas_equalTo(-10);
    }];

    UITapGestureRecognizer *cellTapGes = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(cellTapGesAction:)];
    [cellContainerView addGestureRecognizer:cellTapGes];

    return cellContainerView;
}

- (void)cellTapGesAction:(UITapGestureRecognizer *)tapGes {
    UIView *view = tapGes.view;
    NSInteger selectTag = view.tag;
    if ((selectTag == 3 || selectTag == 4) && ![SmallDecisionsSingletonHelper shareInstance].isVIP) {
        [SmallDecisionsSingletonHelper presentVipViewController];
    } else {
        if (self.callback) {
            self.callback(@(selectTag));
        }
        [SmallDecisionsNavigatorManager dismissViewControllerAnimated:YES completion:nil];
    }
}

- (BOOL)showNavBarCloseButton {
    return YES;
}

@end
